package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.service.IDaijiajingyeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Daijiajingye;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 代驾经营 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/daijiajingye")
public class DaijiajingyeController extends BaseController
{
    private String prefix = "system/daijiajingye";
	
	@Autowired
	private IDaijiajingyeService daijiajingyeService;
	
	@RequiresPermissions("system:daijiajingye:view")
	@GetMapping()
	public String daijiajingye()
	{
	    return prefix + "/daijiajingye";
	}
	
	/**
	 * 查询代驾经营列表
	 */
	@RequiresPermissions("system:daijiajingye:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Daijiajingye daijiajingye)
	{
		startPage();
        List<Daijiajingye> list = daijiajingyeService.selectDaijiajingyeList(daijiajingye);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出代驾经营列表
	 */
	@RequiresPermissions("system:daijiajingye:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Daijiajingye daijiajingye)
    {
    	List<Daijiajingye> list = daijiajingyeService.selectDaijiajingyeList(daijiajingye);
        ExcelUtil<Daijiajingye> util = new ExcelUtil<Daijiajingye>(Daijiajingye.class);
        return util.exportExcel(list, "daijiajingye");
    }
	
	/**
	 * 新增代驾经营
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存代驾经营
	 */
	@RequiresPermissions("system:daijiajingye:add")
	@Log(title = "代驾经营", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Daijiajingye daijiajingye)
	{		
		return toAjax(daijiajingyeService.insertDaijiajingye(daijiajingye));
	}

	/**
	 * 修改代驾经营
	 */
	@GetMapping("/edit/{daijiajingyingId}")
	public String edit(@PathVariable("daijiajingyingId") Integer daijiajingyingId, ModelMap mmap)
	{
		Daijiajingye daijiajingye = daijiajingyeService.selectDaijiajingyeById(daijiajingyingId);
		mmap.put("daijiajingye", daijiajingye);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存代驾经营
	 */
	@RequiresPermissions("system:daijiajingye:edit")
	@Log(title = "代驾经营", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Daijiajingye daijiajingye)
	{		
		return toAjax(daijiajingyeService.updateDaijiajingye(daijiajingye));
	}
	
	/**
	 * 删除代驾经营
	 */
	@RequiresPermissions("system:daijiajingye:remove")
	@Log(title = "代驾经营", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(daijiajingyeService.deleteDaijiajingyeByIds(ids));
	}
	
}
